package cn.net.cfss.fgbp.face.console.controller;

import cn.net.cfss.fgbp.api.console.dto.SysUserLoginLogDto;
import cn.net.cfss.fgbp.api.console.inte.ISysUserLoginLogService;
import cn.net.cfss.fgbp.base.controller.BaseController;
import cn.net.cfss.fgbp.base.page.PageData;
import cn.net.cfss.fgbp.face.console.util.ReturnUtil;
import cn.net.cfss.fgbp.face.console.vo.BaseParas;
import cn.net.cfss.fgbp.log.influxdb.ApiDto;
import cn.net.cfss.fgbp.log.statistics.IStatsdLogService;
import cn.net.cfss.fgbp.log.statistics.LogDtoFactory;
import cn.net.cfss.fgbp.log.util.LogStandardUtil;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.UUID;

@RestController
@Slf4j
@RequestMapping("console/loginlog")
public class SysUserLoginLogController extends BaseController {

    @Autowired
    private ISysUserLoginLogService sysUserLoginLogService;

    @ApiOperation("用户详情查询")
    @RequestMapping(value = "/get/{loginLogId}", method = RequestMethod.GET)
    public String get(HttpServletRequest request,@PathVariable Long loginLogId) {
        sysUserLoginLogService.get(loginLogId);
        return ReturnUtil.returnSucc();
    }

    @ApiOperation("用户分页查询")
    @RequestMapping(value = "/query/page", method = RequestMethod.POST)
    public String queryPage(@RequestBody BaseParas paras) {
        SysUserLoginLogDto dto = JSONObject.toJavaObject(paras.getPlain().getJSONObject("search"), SysUserLoginLogDto.class);
        JSONObject pageObj = paras.getPlain();
        PageData<SysUserLoginLogDto> pageData = PageData.createPagerData(pageObj.getIntValue("pageSize"), pageObj.getIntValue("pageNum"), dto);
        pageData = sysUserLoginLogService.queryByPage(pageData);
        return ReturnUtil.returnSucc(pageData, pageData.getRows());
    }

}
